Skip to content

<fix>[core]: register IPv6 prefer config#4146

Open
MatheMatrix wants to merge 15 commits into
feature-5.5.28-IPv6-management-networkfrom
sync/shixin.ruan/shixin-ZSTAC-79206@@2
Open

<fix>[core]: register IPv6 prefer config#4146
MatheMatrix wants to merge 15 commits into
feature-5.5.28-IPv6-management-networkfrom
sync/shixin.ruan/shixin-ZSTAC-79206@@2

Conversation

@MatheMatrix
Copy link
Copy Markdown
Owner

Register management.server/prefer.ipv6 as a GlobalConfig so
QueryGlobalConfig and runtime updates work. Keep the startup system
property override and fall back to the legacy global property before
GlobalConfig is available.

Resolves: ZSTAC-85520

Change-Id: Ia59515ce9a9a29eeecb9b5ab7d83057823089884

sync from gitlab !10050

shixin.ruan added 12 commits May 27, 2026 12:43
Register management.server/prefer.ipv6 as a GlobalConfig so
QueryGlobalConfig and runtime updates work. Keep the startup system
property override and fall back to the legacy global property before
GlobalConfig is available.

Resolves: ZSTAC-85520

Change-Id: Ia59515ce9a9a29eeecb9b5ab7d83057823089884
Use bare IPv6 for ssh command targets. Keep bracketed IPv6 only for scp
host:path syntax.

Resolves: ZSTAC-85522

Change-Id: I0d655ccf654634edb109f9c8025a7b70dbf34da4
Use a callback URL in the same IP family as the virtual router
management NIC. This keeps IPv4-only vrouter agents reachable when MN
is dual-stack and its default management IP is IPv6.

Resolves: ZSTAC-85527

Change-Id: Iaa630fc59d30c2675db7bbe47cb1b7c8d58bb023
Console proxy returned the MN IPv6 address to clients but selected the
listen address from agentIp, which is 127.0.0.1 for the management-node
agent. Use the client-facing proxy hostname to choose the wildcard
listen address so IPv6 console URLs are reachable.

Resolves: ZSTAC-85595

Change-Id: Ief18c9b847f0e0c050ce993a50244533614fd2b8
Fixes ZSTAC-85605 and ZSTAC-85612.

SSH keeps raw IPv6 hosts while SCP brackets IPv6 paths.
Ansible callback checker now passes -6 for IPv6 nc and nmap.
Hotfix verified on 172.24.249.182.

Resolves: ZSTAC-79206

Change-Id: Iaa7204e638335c7bf1496b2cd5e0314081e598cb
VXLAN CIDR system tags can contain IPv6 values with double colon. Split
tag fields only outside token braces so patterned tag matching and
token extraction keep IPv6 CIDRs intact.

Resolves: ZSTAC-85618

Change-Id: Ie74a3ac89e1d728953bcaab74146d25e7a7e2edc
Remove the customer-facing management.server.prefer.ipv6 switch.\n\nUse
explicit management.server.ip first. When it is not configured, keep
IPv4 as the default and fall back to IPv6 only if no IPv4 is
available.\n\nWaterfall CR: ZSTAC-79206 CR-001

Change-Id: I14e3e6b3fdad2e4e109d4f9c9f3f344356866762
Build KVM agent HTTP URLs through the IPv6-safe host formatter so live
migration cleanup and migrate calls bracket IPv6 host addresses.

Resolves: ZSTAC-85636

Change-Id: I0c9fa1eecf7d6eef778cbb4568123d7bd3a836ec
Allow patterned system tag values to contain IPv6 token text.
Use dual-stack CIDR matching for migration network selection.
Add focused management IPv6 regression assertions.

Resolves: ZSTAC-85638

Change-Id: I32f3d1111aa3358fd26da6a3afb23111154f9058
Resolves: ZSTAC-79206

Change-Id: I485bade7bd875e2b492174f4c2e7e710fee1c0b3
Fixes ZSTAC-85690.\n\nAllow IPv6 ranges on System L3 networks for
management network IPv6.\nAlso allow virtual router offerings to use
IPv6 management L3.

Change-Id: If46c0ab86c018f72d0138df6363689f85dbecaeb
Parse system tag delimiters only outside token braces when matching
actual tag values.

Resolves: ZSTAC-85618

Change-Id: I7d0a9cf3146a513e56ba0d6d3bff3685bc4716e0
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)

Review profile: CHILL

Plan: Pro

Run ID: 4a5b71c3-5e34-4cf8-a603-d6767209a338

📥 Commits

Reviewing files that changed from the base of the PR and between 2b2d2fb and 9c58c88.

📒 Files selected for processing (3)
  • core/src/main/java/org/zstack/core/Platform.java
  • plugin/applianceVm/src/main/java/org/zstack/appliancevm/ApplianceVmFacadeImpl.java
  • utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java

Walkthrough

该 PR 统一了 ZStack 对 IPv6 双栈网络的处理,移除了管理服务器 IPv6 偏好配置,重构了管理 IP 选择策略、回调 URL 体系,改进了网络工具与 URL/SSH/SCP 构造,并通过 token-aware 标签解析支持包含 IPv6 CIDR 的 patterned tag,涵盖 19 个文件的功能更新与 9 个测试用例的扩展。

Changes

IPv6 管理网络与回调 URL 体系

Layer / File(s) Summary
管理服务器 IP 选择与全局属性更新
core/src/main/java/org/zstack/core/Platform.java, core/src/main/java/org/zstack/core/CoreGlobalProperty.java, plugin/applianceVm/src/main/java/org/zstack/appliancevm/ApplianceVmFacadeImpl.java
Platform.selectManagementServerIp 简化为仅接收地址集合,选择策略固定优先 IPv4;新增 getManagementServerIpsWithLocalFallback 收集启用网卡的非回环 IP,以及 getRouteSourceIp 通过 ip route get 查询源 IP;CoreGlobalProperty 删除 MANAGEMENT_SERVER_PREFER_IPV6 并新增 CHRONY_SERVERS 与 MN_VIP;ApplianceVmFacadeImpl 引导参数改用本地 IP 列表来源。
虚拟路由器回调请求头与 URL 构造
plugin/virtualRouterProvider/src/main/java/org/zstack/network/service/virtualrouter/VirtualRouterManagerImpl.java
VirtualRouterManagerImpl 注入 RESTFacade,实现 buildAgentCallbackUrlHeaders 通过 selectManagementIpForAgent 选择合适管理服务器 IP(优先路由源 IP),调用 restf.buildCallbackUrl 生成回调 URL 并返回包含 CALLBACK_URL 的请求头;buildUrl 改用 IPv6NetworkUtils.formatHostForUrl 适配 IPv6 主机格式。

网络工具与 URL/SSH/SCP 统一处理

Layer / File(s) Summary
IPv6 方括号与 CIDR 工具库
utils/src/main/java/org/zstack/utils/network/IPv6NetworkUtils.java, utils/src/main/java/org/zstack/utils/network/NetworkUtils.java
IPv6NetworkUtils 新增 stripHostUrlBrackets 去除 URL 方括号;NetworkUtils 新增 filterIpsInCidr 替换原 IPv4 专用方法,改进 fmtCidr 使用 getNetworkAddressFromCidr 支持通用 IP。
回调检查与 SSH/SCP 目标格式化
core/src/main/java/org/zstack/core/ansible/CallBackNetworkChecker.java, utils/src/main/java/org/zstack/utils/ssh/SshShell.java, utils/src/main/java/org/zstack/utils/ssh/Ssh.java
CallBackNetworkChecker 新增 buildCallbackCheckScript 根据回调 IP 版本选择 -6 选项并剥离方括号;SshShell.formatSshTarget 改用 stripHostUrlBrackets,runScript 调整参数构造方式;Ssh.createScpCommand 改用 formatScpTarget。
Agent 与存储 URL 统一构造
plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java, plugin/zbs/src/main/java/org/zstack/storage/zbs/MdsUri.java, plugin/zbs/src/main/java/org/zstack/storage/zbs/ZbsAgentUrl.java, plugin/ceph/src/main/java/org/zstack/storage/ceph/primary/CephPrimaryStorageBase.java
KVMHost 新增 buildAgentUrl 静态方法替换多处 UriComponentsBuilder 拼装;MdsUri 使用 stripHostUrlBrackets 处理 SSH URL;ZbsAgentUrl 改用 IPv6NetworkUtils.buildHttpUrl 与 appendPath 助手;Ceph 迁移至 filterIpsInCidr。

网络校验规则放宽

Layer / File(s) Summary
L3 与虚拟路由器验证调整
network/src/main/java/org/zstack/network/l3/L3NetworkApiInterceptor.java, plugin/virtualRouterProvider/src/main/java/org/zstack/network/service/virtualrouter/VirtualRouterApiInterceptor.java
L3NetworkApiInterceptor.validateIpv6Range 删除对 System 网络阻止 IPv6 range 的检查;VirtualRouterApiInterceptor.validate 删除管理网络必须支持 IPv4 的约束。

系统标签 Token-aware 解析

Layer / File(s) Summary
TagUtils Token-aware 解析
utils/src/main/java/org/zstack/utils/TagUtils.java
TagUtils.parse 与 isMatch 改用 token 感知拆分,新增私有工具方法追踪花括号嵌套深度,避免在 token 内错误拆分分隔符,支持带 IPv6 CIDR 的 patterned tag。

集成测试扩展

Layer / File(s) Summary
控制台代理 IPv6 配置测试
test/src/test/groovy/org/zstack/test/integration/console/ConsoleProxyCase.groovy
新增对 IPv6 overridden IP 更新、全局属性同步与 selectConsoleProxyHostname IPv6 格式(方括号包裹)的验证。
管理网络与工具链 IPv6 测试
test/src/test/groovy/org/zstack/test/integration/core/ManagementNetworkIpv6Case.groovy
删除 prefer 相关测试,新增 KVM agent URL、SSH/SCP 目标格式、回调脚本 IPv6 选项、CIDR 筛选、VXLAN 系统标签与 patterned tag 解析的验证。
ZBS 存储 IPv6 URL 测试
test/src/test/groovy/org/zstack/test/integration/storage/primary/addon/zbs/ZbsPrimaryStorageCase.groovy
新增 testZbsMdsUriAndAgentUrlSupportIpv6,验证 MdsUri 与 primaryStorageUrl 对 IPv6 地址(含方括号)的支持与根路径拼接。

错误码常量扩展

Layer / File(s) Summary
CloudOperationsErrorCode 常量
utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java
新增 ORG_ZSTACK_VPC_HA_10021 与 ORG_ZSTACK_VPC_HA_10022 两个错误码常量。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 移除偏好,双栈齐声,
IPv6 方括号去其轻,
路由源 IP 寻源地,
Token-aware 标签不拆行,
统一 URL 从此整整洁!


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 1.20% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive 标题虽然相关但不准确,描述的是移除IPv6偏好配置并重构为固定策略,而非注册/启用该配置。 建议标题改为更准确的表述,如 '[core]: remove IPv6 preference config and refactor to fixed strategy' 或类似内容以准确反映实际变更。
Description check ❓ Inconclusive 描述内容与实际变更存在不符:PR描述称注册management.server/prefer.ipv6配置,但代码变更实际是删除该配置字段并移除相关逻辑。 建议更新描述以准确反映变更意图:移除IPv6偏好配置、重构选择策略为固定IPv4优先策略,以及添加新的全局属性(CHRONY_SERVERS、MN_VIP)等。
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sync/shixin.ruan/shixin-ZSTAC-79206@@2

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.42.3)
utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
plugin/zbs/src/main/java/org/zstack/storage/zbs/ZbsAgentUrl.java (1)

10-19: ⚡ Quick win

建议在路径拼接时统一处理前后斜杠,避免出现 //

当前实现在 sb/ 结尾且 path 也以 / 开头时会生成双斜杠,建议在 appendPath 中做一次归一化。

♻️ 建议修改
 private static void appendPath(StringBuilder sb, String path) {
     if (path == null || path.isEmpty()) {
         return;
     }

-    if (!path.startsWith("/")) {
-        sb.append("/");
-    }
-    sb.append(path);
+    boolean sbEndsWithSlash = sb.length() > 0 && sb.charAt(sb.length() - 1) == '/';
+    boolean pathStartsWithSlash = path.startsWith("/");
+
+    if (sbEndsWithSlash && pathStartsWithSlash) {
+        sb.append(path.substring(1));
+    } else if (!sbEndsWithSlash && !pathStartsWithSlash) {
+        sb.append('/').append(path);
+    } else {
+        sb.append(path);
+    }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugin/zbs/src/main/java/org/zstack/storage/zbs/ZbsAgentUrl.java` around
lines 10 - 19, appendPath currently can produce double slashes when sb ends with
'/' and path starts with '/'; update the appendPath(StringBuilder sb, String
path) to normalize boundaries by removing a trailing slash from sb or a leading
slash from path before appending so exactly one '/' separates segments (handle
null/empty path as before and ensure you still append a single '/' when needed).
Use the existing sb and path parameters and make this normalization inside
appendPath so callers need no changes.
header/src/main/java/org/zstack/header/rest/RESTFacade.java (1)

91-91: ⚡ Quick win

为新增接口方法补充 Javadoc。

RESTFacade 是公共接口,Line 91 新增方法缺少方法级文档,后续调用约束不够清晰。建议补充参数与返回值语义说明。

建议修改
+    /**
+     * Build callback URL with the given host name using current RESTFacade port/path.
+     *
+     * `@param` hostName callback host name or IP
+     * `@return` callback URL
+     */
     String buildCallbackUrl(String hostName);

As per coding guidelines "接口方法不应有多余的修饰符(例如 public),且必须配有有效的 Javadoc 注释。"

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@header/src/main/java/org/zstack/header/rest/RESTFacade.java` at line 91,
RESTFacade 接口中新加的方法 buildCallbackUrl(String hostName) 缺少方法级 Javadoc;请为方法 String
buildCallbackUrl(String hostName) 添加完整的 Javadoc,明确说明参数 hostName
的含义(例如主机名或主机地址、是否允许为 null/空、预期格式)以及返回值语义(例如返回用于回调的完整 URL、何时可能返回 null
或抛出异常),并确保接口方法不带多余的修饰符以符合编码规范。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@utils/src/main/java/org/zstack/utils/TagUtils.java`:
- Around line 49-50: The fast-return in isMatch that does "if
(fmt.indexOf(TAG_DELIMITER) == -1) return fmt.equals(tag);" wrongly treats
templates like "{token}" as non-matching; instead, change this branch to
consider template tokens: when TAG_DELIMITER is absent in fmt, return true if
fmt.equals(tag) OR fmt itself is a single token template that should match any
valid tag value (e.g., fmt.matches("\\{[^}]+}")) and tag is non-empty (or
matches the expected token pattern). Update isMatch to use these checks
(referencing isMatch, fmt, tag, and TAG_DELIMITER) so token-template strings are
treated as matching rather than always false.

---

Nitpick comments:
In `@header/src/main/java/org/zstack/header/rest/RESTFacade.java`:
- Line 91: RESTFacade 接口中新加的方法 buildCallbackUrl(String hostName) 缺少方法级
Javadoc;请为方法 String buildCallbackUrl(String hostName) 添加完整的 Javadoc,明确说明参数
hostName 的含义(例如主机名或主机地址、是否允许为 null/空、预期格式)以及返回值语义(例如返回用于回调的完整 URL、何时可能返回 null
或抛出异常),并确保接口方法不带多余的修饰符以符合编码规范。

In `@plugin/zbs/src/main/java/org/zstack/storage/zbs/ZbsAgentUrl.java`:
- Around line 10-19: appendPath currently can produce double slashes when sb
ends with '/' and path starts with '/'; update the appendPath(StringBuilder sb,
String path) to normalize boundaries by removing a trailing slash from sb or a
leading slash from path before appending so exactly one '/' separates segments
(handle null/empty path as before and ensure you still append a single '/' when
needed). Use the existing sb and path parameters and make this normalization
inside appendPath so callers need no changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)

Review profile: CHILL

Plan: Pro

Run ID: cab5d952-05ef-4595-87b2-6204fdd2f192

📥 Commits

Reviewing files that changed from the base of the PR and between bc00c9c and e40f7f8.

📒 Files selected for processing (25)
  • console/src/main/java/org/zstack/console/ConsoleProxyBase.java
  • core/src/main/java/org/zstack/core/CoreGlobalProperty.java
  • core/src/main/java/org/zstack/core/Platform.java
  • core/src/main/java/org/zstack/core/ansible/CallBackNetworkChecker.java
  • core/src/main/java/org/zstack/core/rest/RESTFacadeImpl.java
  • header/src/main/java/org/zstack/header/rest/RESTFacade.java
  • network/src/main/java/org/zstack/network/l3/L3NetworkApiInterceptor.java
  • plugin/ceph/src/main/java/org/zstack/storage/ceph/primary/CephPrimaryStorageBase.java
  • plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java
  • plugin/virtualRouterProvider/src/main/java/org/zstack/network/service/virtualrouter/VirtualRouter.java
  • plugin/virtualRouterProvider/src/main/java/org/zstack/network/service/virtualrouter/VirtualRouterApiInterceptor.java
  • plugin/virtualRouterProvider/src/main/java/org/zstack/network/service/virtualrouter/VirtualRouterManager.java
  • plugin/virtualRouterProvider/src/main/java/org/zstack/network/service/virtualrouter/VirtualRouterManagerImpl.java
  • plugin/virtualRouterProvider/src/main/java/org/zstack/network/service/virtualrouter/lifecycle/VirtualRouterDeployAgentFlow.java
  • plugin/virtualRouterProvider/src/main/java/org/zstack/network/service/virtualrouter/vyos/VyosConnectFlow.java
  • plugin/zbs/src/main/java/org/zstack/storage/zbs/MdsUri.java
  • plugin/zbs/src/main/java/org/zstack/storage/zbs/ZbsAgentUrl.java
  • test/src/test/groovy/org/zstack/test/integration/console/ConsoleProxyCase.groovy
  • test/src/test/groovy/org/zstack/test/integration/core/ManagementNetworkIpv6Case.groovy
  • test/src/test/groovy/org/zstack/test/integration/storage/primary/addon/zbs/ZbsPrimaryStorageCase.groovy
  • utils/src/main/java/org/zstack/utils/TagUtils.java
  • utils/src/main/java/org/zstack/utils/network/IPv6NetworkUtils.java
  • utils/src/main/java/org/zstack/utils/network/NetworkUtils.java
  • utils/src/main/java/org/zstack/utils/ssh/Ssh.java
  • utils/src/main/java/org/zstack/utils/ssh/SshShell.java
💤 Files with no reviewable changes (3)
  • network/src/main/java/org/zstack/network/l3/L3NetworkApiInterceptor.java
  • core/src/main/java/org/zstack/core/CoreGlobalProperty.java
  • plugin/virtualRouterProvider/src/main/java/org/zstack/network/service/virtualrouter/VirtualRouterApiInterceptor.java

Comment on lines +49 to 50
if (fmt.indexOf(TAG_DELIMITER) == -1) {
return fmt.equals(tag);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

isMatch 的无分隔符快速返回引入了 token 模板匹配回归。

Line 49-50 现在直接 fmt.equals(tag),会把 "{token}" 这类合法模板错误判定为不匹配。

建议修复
+        if (tag == null) {
+            return false;
+        }
-        if (fmt.indexOf(TAG_DELIMITER) == -1) {
+        if (fmt.indexOf(TAG_DELIMITER) == -1 && !isTokenField(fmt)) {
             return fmt.equals(tag);
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@utils/src/main/java/org/zstack/utils/TagUtils.java` around lines 49 - 50, The
fast-return in isMatch that does "if (fmt.indexOf(TAG_DELIMITER) == -1) return
fmt.equals(tag);" wrongly treats templates like "{token}" as non-matching;
instead, change this branch to consider template tokens: when TAG_DELIMITER is
absent in fmt, return true if fmt.equals(tag) OR fmt itself is a single token
template that should match any valid tag value (e.g., fmt.matches("\\{[^}]+}"))
and tag is non-empty (or matches the expected token pattern). Update isMatch to
use these checks (referencing isMatch, fmt, tag, and TAG_DELIMITER) so
token-template strings are treated as matching rather than always false.

Format IPv6 vRouter agent URLs with brackets and select the MN callback
source IP from the route to the agent.\n\nAlso expose local
non-loopback IPs to appliance VM bootstrap selection so dual-stack MNs
can provide an IPv6 managementNodeIp while keeping management.server.ip
on IPv4.

Resolves: ZSTAC-85692

Change-Id: If1612db0b39389084a0501fa1065b15cac1d9990
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@core/src/main/java/org/zstack/core/Platform.java`:
- Line 1068: The getManagementServerIps() method currently calls
getLocalNonLoopbackIps(), which widens its semantics and risks returning
non-management network IPs; change getManagementServerIps() to stop adding
getLocalNonLoopbackIps() directly and instead implement a focused fallback
helper (e.g., a new method or flag) that is only used by callers that explicitly
need any non-loopback addresses; update callers
VirtualRouterManagerImpl.selectManagementIpForAgent() and
ApplianceVmFacadeImpl.putManagementNodeBootstrapParams() to invoke the new
explicit fallback when appropriate (and keep existing behavior of
getManagementServerIp4/6 and vrManagementCidrs filtering intact), ensuring any
fallback result is further filtered by management CIDRs or explicit
management-interface selection before being returned.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)

Review profile: CHILL

Plan: Pro

Run ID: 5457217c-23b4-4f06-8a71-7a52a0709b60

📥 Commits

Reviewing files that changed from the base of the PR and between e40f7f8 and 2b2d2fb.

📒 Files selected for processing (2)
  • core/src/main/java/org/zstack/core/Platform.java
  • plugin/virtualRouterProvider/src/main/java/org/zstack/network/service/virtualrouter/VirtualRouterManagerImpl.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugin/virtualRouterProvider/src/main/java/org/zstack/network/service/virtualrouter/VirtualRouterManagerImpl.java

Comment thread core/src/main/java/org/zstack/core/Platform.java
shixin.ruan added 2 commits May 30, 2026 13:26
Merge latest feature branch and keep IPv6 vRouter callback URL behavior.

Resolves: ZSTAC-79206

Change-Id: I67d1c41833cc649b12239223f2449bf297fadad7
Keep getManagementServerIps narrow and use explicit local fallback only
for appliance VM bootstrap CIDR selection.

Resolves: ZSTAC-79206

Change-Id: Ib90e405fcef57b0dcbe03703ddcf2fe92682745b
public static String selectManagementServerIp(Collection<InetAddress> addresses, boolean preferIpv6) {
public static List<String> getManagementServerIpsWithLocalFallback() {
LinkedHashSet<String> ips = new LinkedHashSet<>(getManagementServerIps());
ips.addAll(getLocalNonLoopbackIps());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment from shixin.ruan:

有效,已按最小范围修复。缺陷类型:API 语义/多网卡回调候选扩大。根因是 getManagementServerIps() 被扩展为包含所有本机非回环地址,确实会破坏旧 API 的“管理地址列表”契约。修改:9c58c88c32 中恢复 getManagementServerIps() 只返回 management.server.ip / ip4 / ip6;新增 getManagementServerIpsWithLocalFallback(),仅在 ApplianceVmFacadeImpl bootstrap 且后续会按 vRouter management CIDR 过滤的路径使用。VirtualRouterManagerImpl 仍优先使用 Platform.getRouteSourceIp(agentIp),fallback 回窄化后的管理地址列表。验证:mvn -pl utils -DskipTests install;mvn -pl utils,header,core,plugin/applianceVm,plugin/virtualRouterProvider -DskipTests compile;zstack/test 下 mvn -DskipTests test-compile 均通过。剩余风险:本次不引入按网卡名选择管理口的新策略,只收窄旧 API 语义并保留 bootstrap CIDR 过滤 fallback。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants